package hamiltonianExemple;

import org.jgraph.graph.DefaultEdge;
import org.jgrapht.alg.HamiltonianCycle;
import org.jgrapht.graph.SimpleWeightedGraph;

public class HemiltonianCycle {

	
	public static void main(String[] args) {
		
		SimpleWeightedGraph<String, DefaultEdge> WeihtedGraph = 
				new SimpleWeightedGraph<String, DefaultEdge>(DefaultEdge.class);
		
		
		System.out.println("Exemplo de entrada: ");
		System.out.println("v={a,b,c,d,e}");
		System.out.println("e={ab,ac,ad,ae,bc,bd,be,cd,ce,de}");
		
		WeihtedGraph.addVertex("a");
		WeihtedGraph.addVertex("b");
		WeihtedGraph.addVertex("c");
		WeihtedGraph.addVertex("d");
		WeihtedGraph.addVertex("e");
		
		
		
		WeihtedGraph.addEdge("a", "b");
		WeihtedGraph.addEdge("a", "c");
		WeihtedGraph.addEdge("a", "d");
		WeihtedGraph.addEdge("a", "e");
		WeihtedGraph.addEdge("b", "c");
		WeihtedGraph.addEdge("b", "d");
		WeihtedGraph.addEdge("b", "e");
		WeihtedGraph.addEdge("c", "d");
		WeihtedGraph.addEdge("c", "e");
		WeihtedGraph.addEdge("d", "e");
		
		
		HamiltonianCycle hc = new HamiltonianCycle();
		
		System.out.println(hc.getApproximateOptimalForCompleteGraph(WeihtedGraph).toString());
	}
	
	
	
	
	
	
}
